package com.SmartCare.controller.manager;

import com.SmartCare.common.Result;
import com.SmartCare.service.AttendanceService;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
@RequestMapping("/manager-attendance")
@Api(tags = "管理端线下访问模块")
@Slf4j
public class ManagerAttendanceController {
    @Resource
    private AttendanceService attendanceService;

    //获取排行榜数据
    @GetMapping("/query-data")
    public Result getAttendanceData(@RequestParam String careHomeName) {
        return attendanceService.getAttendanceData(careHomeName);
    }

    //获取本周排行榜数据
    @GetMapping("/query-week")
    public Result getWeekAttendance(@RequestParam String careHomeName) {
        return attendanceService.getWeekAttendance(careHomeName);
    }

    //获取线下到访记录
    @GetMapping("/query-records")
    public Result getAttendanceRecords(@RequestParam String careHomeName,
                                       @RequestParam Integer pageNum,
                                       @RequestParam Integer pageSize,
                                       @RequestParam String keyword,
                                       @RequestParam String type) {
        return attendanceService.search(careHomeName, pageNum, pageSize, keyword, type);
    }

    // 根据用户线下访问总时长排行
    @GetMapping("/top-by-user")
    public Result topByUser(@RequestParam String careHomeName,
                            @RequestParam String startTime,
                            @RequestParam String endTime) {
        return attendanceService.topByUser(careHomeName, startTime, endTime);
    }
}
